package com.zbkj.crmeb.enums;

import java.util.Objects;

import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * 商品上架方式：1全部上架商品 2部分精选商品
 */
public enum ShopProductSelectTypeEnum implements IEnum<Integer> {

	/**
	 * 全部上架商品
	 */
    ALL(1, "全部上架商品"),

	/**
	 * 部分精选商品
	 */
    PART(2, "部分精选商品"),

    ;

    private final Integer code;
    private final String msg;

    ShopProductSelectTypeEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    @JsonCreator
    public static ShopProductSelectTypeEnum valueOf(Integer code) {
        for (ShopProductSelectTypeEnum value : values()) {
            if (code.equals(value.getCode())) {
                return value;
            }
        }
        return null;
    }

    @Override
    @JsonValue
    public Integer getValue() {
        return code;
    }

    public static ShopProductSelectTypeEnum getEnumByCode(Integer code) {
        for (ShopProductSelectTypeEnum value : values()) {
            if (Objects.equals(value.getCode(), code)) {
                return value;
            }
        }
        return null;
    }

    public static String getMsgByCode(Integer code) {
        for (ShopProductSelectTypeEnum value : values()) {
            if (Objects.equals(value.getCode(), code)) {
                return value.msg;
            }
        }
        return null;
    }
}

